package algorithm.dichotomy.leetcode;

/**
 * @author: 柒月
 * @date: 2025/5/1 下午7:00
 * @version: 1.0
 */
public class Problem74 {

    // https://leetcode.cn/problems/search-a-2d-matrix/
    public boolean searchMatrix(int[][] matrix, int target) {
        int i = 0, j = matrix[0].length - 1;
        while (i < matrix.length && j >= 0) {
            if (matrix[i][j] == target) {
                return true;
            } else if (matrix[i][j] < target) {
                i++;
            }else {
                j--;
            }
        }
        return false;
    }
}
